//package com.newcapec.modules.terminal.mqtt;
//
//import com.alibaba.fastjson.JSON;
//import com.newcapec.modules.pass.entity.PassRecordEntity;
//import com.newcapec.modules.pass.service.PassRecordService;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.shiro.authc.credential.PasswordService;
//import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
//import org.eclipse.paho.client.mqttv3.MqttCallback;
//import org.eclipse.paho.client.mqttv3.MqttMessage;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//@Component
//@Slf4j
//public class OnMessageCallback implements MqttCallback {
//    @Autowired
//    private PassRecordService passRecordService;
//    public void connectionLost(Throwable cause) {
//        // 连接丢失后，一般在这里面进行重连
//        log.info("连接断开，可以做重连");
//    }
//
//    public void messageArrived(String topic, MqttMessage message) throws Exception {
//        // subscribe后得到的消息会执行到这里面
//       log.info("接收消息主题:" + topic);
//        log.info("接收消息Qos:" + message.getQos());
//        log.info("接收消息内容:" + new String(message.getPayload()));
//        PassRecordEntity passRecordEntity = JSON.parseObject(new String(message.getPayload()),PassRecordEntity.class);
//        passRecordService.add(passRecordEntity);
//    }
//
//    public void deliveryComplete(IMqttDeliveryToken token) {
//        log.info("消息发送完成---------" + token.isComplete());
//    }
//}
